package com.gqr.threadpool;

import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;

/**
 * Copyright (C), 2020-2024,gqr
 * FileName:ScheduledThreadPoolTest
 * author:guqingrong
 * Date:2024-05-06 21:42
 * Description: 演示newScheduledThreadPool
 * History:
 * <author>    <time>    <version>    <desc>
 * 作者姓名     修改时间     版本号        描述
 */
public class ScheduledThreadPoolTest {
    public static void main(String[] args) {
        ScheduledExecutorService threadPool = Executors.newScheduledThreadPool(10);
        // 延迟5秒运行
//        threadPool.schedule(new Task(),5, TimeUnit.SECONDS);

        // 以一定频率重复运行的
        threadPool.scheduleAtFixedRate(new Task(),1,3,TimeUnit.SECONDS);
    }
}
